package util;

/**
 * The implementation of a star.
 */
public class Star extends Shape {
	
	private int _a;
	private int _b;
	private int _c;
	@SuppressWarnings("unused")
	private int _d;
	private int _e;
	private int _f;
	private PAGColor _center;
	
	/**
	 * Creates an empty star.
	 */
	public Star() {
		setEmpty();
	}
	
	public Star(int up, int vert, int down)
	{
		_center = PAGColor.CENTER;
		_a = vert;
		_b = up;
		_c = down;
		_d = vert;
		_e = up;
		_f = down;
	}
	
	public void setUp(PAGColor color)
	{
		setB(getNumber(color));
		setE(getNumber(color));
	}
	
	public int getUp()
	{
		return getB();
	}
	
	public PAGColor getUpColor()
	{
		return getColor(getB());
	}
	
	public void setVertical(PAGColor color)
	{
		setA(getNumber(color));
		setD(getNumber(color));
	}
	
	public int getVertical()
	{
		return getA();
	}
	
	public PAGColor getVerticalColor()
	{
		return getColor(getA());
	}
	
	public void setDown(PAGColor color)
	{
		setC(getNumber(color));
		setF(getNumber(color));
	}
	
	public int getDown()
	{
		return getF();
	}
	
	public PAGColor getDownColor()
	{
		return getColor(getC());
	}
	
	public PAGColor getCenterColor()
	{
		return getCenter();
	}
	
	private int getA() {
		return _a;
	}

	private void setA(int _a) {
		this._a = _a;
	}

	private int getB() {
		return _b;
	}

	private void setB(int _b) {
		this._b = _b;
	}

	private int getC() {
		return _c;
	}

	private void setC(int _c) {
		this._c = _c;
	}

	private void setD(int _d) {
		this._d = _d;
	}

	private void setE(int _e) {
		this._e = _e;
	}

	private int getF() {
		return _f;
	}

	private void setF(int f) {
		this._f = f;
	}

	private PAGColor getCenter() {
		return _center;
	}


	
	@Override
	public String toString() {
		return "Star: " + _e + " - " + _a + " - " + _f;
	}

	/**
	 * Makes this star empty (grey).
	 * 
	 * @return the star
	 */
	public Star setEmpty() {
		_center = PAGColor.EMPTY;
		_a = 0;
		_b = 0;
		_c = 0;
		_d = 0;
		_e = 0;
		_f = 0;
		return this;
	}
	
	public void setColor(PAGColor color)
	{
		_center = color;
		setA(getNumber(color));
		setB(getNumber(color));
		setC(getNumber(color));
		setD(getNumber(color));
		setE(getNumber(color));
		setF(getNumber(color));
	}

	public int getColorByDirection(int direction) {
		switch (direction)
		{
		case -1:
			return getC();
		case 0:
			return getA();
		case 1:
			return getB();
		default:
			throw new IllegalArgumentException("Star direction must be -1, 0 or 1. Not " + direction);
		}
	}
}
